<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>登录</h2>
用户名：<input type="text" id="username"> <br>
密码 ：<input type="text" id="password"> <br>
<button onclick="login()">登录</button>

<script>

    function login() {
        const username = document.getElementById("username").value;
        const password = document.getElementById("password").value;
        // fetch是一个前端调用后台api接口的请求方式，类似于ajax
        fetch('/user/login?username=' + username + "&password=" + password).then(res=>res.text()).then(res => {
            if (res === 'success') {
                location.href = '/index.html'
            }
        })
    }
</script>
</body>
</html>
